<!DOCTYPE HTML>
<html>
<head>
<title>${action.getText('view.index.title')}</title>
<#include "include.ftl" />
</head>
<body class="easyui-layout" id="index_layout_${action_id}" oncontextmenu="return false;" >
<#if sessionUser?? >
	<#if sessionUser.getMType()=='MSY_APOTHECARY'>
		<script type="text/javascript">
			window.location.href = '../../chatstage/index.html';
		</script>
	<#else>
		<div data-options="region:'north',href:'layout_top_banner.htm'" style="height: 60px;overflow: hidden;" class="logo"></div>
		<div data-options="region:'west',title:'${action.getText('view.index.left_menu.title')}',href:'layout_left_menu.htm'" style="width: 200px;overflow: hidden;"></div>
		<div data-options="region:'center',title:'${action.getText('view.index.center_main.title')}',href:'layout_center_main.htm'" style="overflow: hidden;"></div>
		<!--<div data-options="region:'east',title:'${action.getText('view.index.right_tool.title')}',href:'layout_right_tools.htm'" style="width: 200px;overflow: hidden;"></div>-->
		<div data-options="region:'south',href:'layout_footer.htm'" style="height: 27px;overflow: hidden;"></div>
	</#if>
<#else>
	<script type="text/javascript">
		var bg_login_refresh_state = true;
		$(function() {
			$.get('layout_right_corner_alert.json',{},function(json){//登录提示
				if(json){
					$.messager.show({
						title:'${action.getText('view.right.corner.alert.title')}',
						msg:json,
						timeout:5000,
						showType:'slide'
					});
				}
			});
			
			$("#hrpwd").focus(function () {
                $(this).hide();
                $("#rpwd").show().focus();
            });
            $("#rpwd").blur(function () {
                if ($(this).val()=="") {
                    $(this).hide();
                    $("#hrpwd").show();
                }
            });
            $("#hrepwd").focus(function () {
                $(this).hide();
                $("#repwd").show().focus();
            });
            $("#repwd").blur(function () {
                if ($(this).val()=="") {
                    $(this).hide();
                    $("#hrepwd").show();
                }
            });
			
			var formParam = {
				url : 'bg_doAjaxLogin.json',
				success : function(result) {
					if (result=="\"success\"" ) {
						if(bg_login_refresh_state){
							window.location.reload();
						}else{
							$('#user_login_loginDialog').hide();
							refreshCurrentTab();
						}
					} else if(result=="\"chat\""){
						window.location.href = '../../chatstage/index.html';
					} else {
						$.messager.show({
							title : '${action.getProperty('net.esj.background.message','bg.message.alert')}',
							msg : '${action.getText('view.index.login.error')}'
						});
					}
				}
			};
		
			$('#user_login_loginInputForm').form(formParam);
			
			var formParam2 = {
				url : 'bg_doAgencyRegister.json',
				success : function(result) {
					if (result=="\"success\"" ) {
						if(bg_login_refresh_state){
							window.location.reload();
						}else{
							$('#user_login_loginDialog').hide();
							refreshCurrentTab();
						}
					} else {
						$.messager.show({
							title : '${action.getProperty('net.esj.background.message','bg.message.alert')}',
							msg : '注册失败'
						});
					}
				}
			};
			
			$('#user_login_loginInputForm2').form(formParam2);
			
			$("#sobo_login_btn1").hover(function(){
				$("#sobo_login_btn1").css("background", "url(/backstage_res/easyui/themes/bg-icon-00003.png) no-repeat center");
			}, function(){
				$("#sobo_login_btn1").css("background", "url(/backstage_res/easyui/themes/bg-icon-00002.png) no-repeat center");
			});
			$("#sobo_login_btn2").hover(function(){
				$("#sobo_login_btn2").css({"background": "url(/backstage_res/easyui/themes/deep_blue.png) no-repeat center", "color":"#FFF"});
			}, function(){
				$("#sobo_login_btn2").css({"background": "url(/backstage_res/easyui/themes/light_grey.png) no-repeat center", "color":"#333333"});
			});
			
			$("#sobo_login_btn11").hover(function(){
				$("#sobo_login_btn11").css("background", "url(/backstage_res/easyui/themes/deep_blue.png) no-repeat center");
			}, function(){
				$("#sobo_login_btn11").css("background", "url(/backstage_res/easyui/themes/light_blue.png) no-repeat center");
			});
			$("#sobo_login_btn22").hover(function(){
				$("#sobo_login_btn22").css({"background": "url(/backstage_res/easyui/themes/deep_blue.png) no-repeat center", "color":"#FFF"});
			}, function(){
				$("#sobo_login_btn22").css({"background": "url(/backstage_res/easyui/themes/light_grey.png) no-repeat center", "color":"#333333"});
			});
			
			if(window.location.href.indexOf('agency')>0){
				$("#sobo_login_btn2").show();
			}
			
			
			
		});
		
		function show_register(){
			if($("#user_login_loginInputForm2").is(":hidden")){
				$("#user_login_loginInputForm2").show();
				$("#user_login_loginInputForm").hide();
			}else{
				$("#user_login_loginInputForm").show();
				$("#user_login_loginInputForm2").hide();
			}
		}
		
		function check_register(){
			if($("#hospital").val()=="药店名称"){
				return "两次密码不一致";
			}
			if($("#loginname").val()=="登录名称"){
				return "两次密码不一致";
			}
			if($("#rpwd").val()=="请输入密码"){
				return "密码不能为空";
			}
			if($("#repwd").val()!=$("#rpwd").val()){
				return "两次密码不一致";
			}
			return "";
		}
		
		function submit_register(){
			var err = check_register();
			if(err!=""){
				$.messager.show({
							title : '${action.getProperty('net.esj.background.message','bg.message.alert')}',
							msg : err
				});
			}else{
				$.ajax({
					url : 'bg_doAgencyAjaxRegister.json',
					data:{
						hospital : $("#hospital").val(),
					  	loginname : $("#loginname").val(),
					  	rpwd : $("#rpwd").val()},
					dataType : 'JSON',
					success : function(json) {
							if(json.type=='success'){
								$.ajax({
									url : 'bg_doAgencyRegister.json',
									data:{
										hospital : $("#hospital").val(),
					  					loginname : $("#loginname").val(),
					  					rpwd : $("#rpwd").val()},
										dataType : 'JSON',
									success : function(result) {
										if (result=='success' ) {
											if(bg_login_refresh_state){
												window.location.reload();
											}else{
												$('#user_login_loginDialog').hide();
												refreshCurrentTab();
											}
										} else {
											$.messager.show({
												title : '${action.getProperty('net.esj.background.message','bg.message.alert')}',
												msg : '注册失败'
											});
										}
									}
								});
							}else{
								$.messager.show({
								title : '${action.getProperty('net.esj.background.message','bg.message.alert')}',
								msg : json.msg
								});
							}
					}
				});
			}
		}
	</script>
	<div id="user_login_loginDialog" style=" width:100%; height:100%; background:#f8f8f8;">
		<div style=" position:absolute; z-index:1; top:50%; left:50%; width:1014px; height:373px; margin-left:-507px; margin-top:-186px;">
			<form method="post" id="user_login_loginInputForm">
				<#if namespace='/apothecaries-manager'>
					<div style="width:491px; height:281px; padding:92px 0 0 523px; margin:0 auto; background:url(/backstage_res/easyui/themes/bg-icon-0002.png) no-repeat center top;">
					<div style="height:60px; width:368px;">
						<input style="height:60px; width:354px; padding-left:14px; font-size:26px; color:#666666; border:0px none; border:transparent;" name="name" class="easyui-validatebox" data-options="required:true" value="请输入用户名" onFocus="javascript:if(this.value == '请输入用户名') this.value = '';" onblur="javascript:if(this.value == '') this.value = '请输入用户名';" />
					</div>
					<div style="height:60px; width:368px; margin-top:19px;">
						<input style="height:60px; width:354px; padding-left:14px; font-size:26px; color:#666666; border:0px none; border:transparent;" type="password" name="pwd" class="easyui-validatebox" data-options="required:true" style="width: 150px;"  value="******" onFocus="javascript:if(this.value == '******') this.value = '';" onblur="javascript:if(this.value == '') this.value = '******';" />
					</div>
					<div >
						<div id="sobo_login_btn1" style=" margin-top:17px;cursor:pointer; font-size:26px;width:225px; height:60px; line-height:60px; text-align:center; border:0px none; background:url(/backstage_res/easyui/themes/bg-icon-00002.png) no-repeat center;float:left; color:#FFF;" onclick="$('#user_login_loginInputForm').submit();"></div>
						<div id="sobo_login_btn2" style=" margin-top:17px;cursor:pointer; font-size:24px;width:225px; height:60px; line-height:60px; text-align:center; border:0px none; background:url(/backstage_res/easyui/themes/light_grey.png) no-repeat center;float:left; margin-left:22px;display:none;" onclick="show_register();">注&nbsp;&nbsp;册</div>
					</div>
				<#else>
					<div style="width:491px; height:281px; padding:92px 0 0 523px; margin:0 auto; background:url(/backstage_res/easyui/themes/bg-icon-0002.jpg) no-repeat center top;">
					<div style="height:60px; width:368px;">
						<input style="height:60px; width:354px; padding-left:14px; font-size:26px; color:#666666; border:0px none; border:transparent;" name="name" class="easyui-validatebox" data-options="required:true" value="请输入用户名" onFocus="javascript:if(this.value == '请输入用户名') this.value = '';" onblur="javascript:if(this.value == '') this.value = '请输入用户名';" />
					</div>
					<div style="height:60px; width:368px; margin-top:19px;">
						<input style="height:60px; width:354px; padding-left:14px; font-size:26px; color:#666666; border:0px none; border:transparent;" type="password" name="pwd" class="easyui-validatebox" data-options="required:true" style="width: 150px;"  value="******" onFocus="javascript:if(this.value == '******') this.value = '';" onblur="javascript:if(this.value == '') this.value = '******';" />
					</div>
					<div >
						<div id="sobo_login_btn1" style=" margin-top:17px;cursor:pointer; font-size:26px;width:225px; height:60px; line-height:60px; text-align:center; border:0px none; background:url(/backstage_res/easyui/themes/bg-icon-00002.png) no-repeat center;float:left; color:#FFF;" onclick="$('#user_login_loginInputForm').submit();"></div>
						<!--<div id="sobo_login_btn2" style=" margin-top:17px;cursor:pointer; font-size:24px;width:225px; height:60px; line-height:60px; text-align:center; border:0px none; background:url(/backstage_res/easyui/themes/light_grey.png) no-repeat center;float:left; margin-left:22px;display:none;" onclick="show_register();">注&nbsp;&nbsp;册</div>-->
					</div>
				</#if>
				</div>
			</form>
			<form method="post" id="user_login_loginInputForm2" style="display:none">
				<div style="width:491px; height:297px; padding:77px 0 0 523px; margin:0 auto; background:url(/backstage_res/easyui/themes/bg-icon-101.jpg) no-repeat center top;">
					<div style="height:38px; width:368px;">
						<input style="height:38px; width:354px; padding-left:14px; font-size:20px; color:#666666; border:0px none; border:transparent;background:transparent;" name="hospital" id="hospital" class="easyui-validatebox" data-options="required:true,validType:'length[0,30]'" value="药店名称" onFocus="javascript:if(this.value == '药店名称') this.value = '';" onblur="javascript:if(this.value == '') this.value = '药店名称';" />
					</div>
					<div style="height:38px; width:368px; margin-top:9px;">
						<input style="height:38px; width:354px; padding-left:14px; font-size:20px; color:#666666; border:0px none; border:transparent;background:transparent;" name="loginname" id="loginname" class="easyui-validatebox" data-options="required:true,validType:'length[0,30]'" value="登录名称" onFocus="javascript:if(this.value == '登录名称') this.value = '';" onblur="javascript:if(this.value == '') this.value = '登录名称';" />
					</div>
					<div style="height:38px; width:368px; margin-top:9px;">
						<input style="height:38px; width:354px; padding-left:14px; font-size:20px; color:#666666; border:0px none;border:transparent; background:transparent;" type="text" id="hrpwd"  class="easyui-validatebox" data-options="required:true,validType:'ck_password'" style="width: 150px;"  value="请输入密码" />
						<input style="height:38px; width:354px; padding-left:14px; font-size:20px; color:#666666; border:0px none;border:transparent; background:transparent;display:none;" type="password" id="rpwd"  class="easyui-validatebox" data-options="required:true,validType:'ck_password'" style="width: 150px;"  value="" />
					</div>
					<div style="height:38px; width:368px; margin-top:9px;">
						<input style="height:38px; width:354px; padding-left:14px; font-size:20px; color:#666666; border:0px none;border:transparent; background:transparent;" type="text" id="hrepwd"  class="easyui-validatebox" data-options="required:true,validType:'ck_password'" style="width: 150px;"  value="请确认密码" />
						<input style="height:38px; width:354px; padding-left:14px; font-size:20px; color:#666666; border:0px none;border:transparent; background:transparent;display:none;" type="password" id="repwd"  class="easyui-validatebox" data-options="required:true,validType:'ck_password'" style="width: 150px;"  value=""  />
					</div>
					<div >
						<div id="sobo_login_btn11" style=" margin-top:17px;cursor:pointer; font-size:26px;width:150px; height:60px; line-height:60px; text-align:center; border:0px none; background:url(/backstage_res/easyui/themes/light_blue.png) no-repeat center;float:left; color:#FFF;" onclick="submit_register();">立即注册</div>
						<div id="sobo_login_btn22" style=" margin-top:17px;cursor:pointer; font-size:24px;width:150px; height:60px; line-height:60px; text-align:center; border:0px none; background:url(/backstage_res/easyui/themes/light_grey.png) no-repeat center;float:left; margin-left:22px;" onclick="show_register();">返&nbsp;&nbsp;回</div>
						<!-- <a class="easyui-linkbutton" id="test1" >测试</a> -->
					</div>
				</div>
				<script type="text/javascript">
				//扩展验证
				$(function(){
					$.extend($.fn.validatebox.defaults.rules,{
						ck_password:{
							validator:function(value){
								return /^[a-zA-Z0-9]{3,20}$/i.test(value);
							},
							message:'只能包括英文字母、数字,长度3-20.'
						}
						
					});
					/* $('#test1').click(function(){
						alert("hello");
					}); */
				})
					
				</script>
				
			</form>
		</div>
	</div>
				
	
</#if>
	<script type="text/javascript">	
	    $("#download1").click(function(){
	    	$('<div>').dialog({
	    		width : 500,
	    		height : 500,
	    		title:'下载',
	    		href :'down_download.htm',
	    	}); 	    	
    	});
	</script>
</body>

</html>